//
//  SuggestController.m
//  easystudy
//
//  Created by 七 on 16/9/3.
//  Copyright © 2016年 kane. All rights reserved.
//

#import "SuggestController.h"
@interface SuggestController ()<UITextViewDelegate>
{
    NSMutableArray *dataList;
    __weak IBOutlet UITableView *suggestTable;
    IBOutlet UIView *BGView;
    __weak IBOutlet UIView *navView;
    __weak IBOutlet UILabel *titleLbl;
    __weak IBOutlet UILabel *lineLbl;
    
    __weak IBOutlet UIView *contentView;
    __weak IBOutlet UILabel *line1;
    __weak IBOutlet UILabel *line2;
    __weak IBOutlet UILabel *line3;
    __weak IBOutlet UILabel *line4;
    __weak IBOutlet UILabel *noticeLbl;
    __weak IBOutlet UITextView *contentTV;
    __weak IBOutlet UITextField *contactTF;
    
}

@end

@implementation SuggestController

- (void)viewDidLoad {
    [super viewDidLoad];
    dataList = [NSMutableArray array];
    navView.backgroundColor = KKColor_DarkGray_White;
    titleLbl.textColor = KKColor_Black_LightGary;
    lineLbl.backgroundColor = KKColor_NavLineColor;
    suggestTable.backgroundColor = KKColor_DarkWhite_Black;
    
    contentView.backgroundColor = KKColor_Black_White;
    line1.backgroundColor = KKColor_NavLineColor;
    line2.backgroundColor = KKColor_NavLineColor;
    line3.backgroundColor = KKColor_NavLineColor;
    line4.backgroundColor = KKColor_NavLineColor;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

#pragma mark - User Action
- (IBAction)backPress:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)sendPress:(id)sender {
    if (contactTF.text.length == 0) {
        [self.view makeToast:@"请输入联系方式" position:@"center"];
        return;
    }
    if (contentTV.text.length == 0) {
        [self.view makeToast:@"请简单描述您的问题或建议" position:@"center"];
        return;
    }
    NSDictionary *dic = @{@"o_cid":[[UserEntity sharedUser] getUserID],@"o_contact":contactTF.text,@"o_content":contentTV.text};
    [WebService feedBack:dic WithBlock:^(id result, NSError *error) {
        if (!error) {
            if ([result[@"errcode"] integerValue] == 0) {
                [self.view makeToast:@"发送成功，感谢反馈" position:@"center"];
            }else{
                [self.view makeToast:result[@"errmsg"] position:@"center"];
            }
        }
    }];
    [self performSelector:@selector(delayMethod) withObject:nil afterDelay:2.0f];
}

- (void)delayMethod
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)textViewDidChange:(UITextView *)textView
{
    noticeLbl.hidden = contentTV.text.length > 0;
}

@end
